package org.example.bumenguanli.mapper;

import org.apache.ibatis.annotations.*;
import org.example.bumenguanli.pojo.Clazz;
import org.example.bumenguanli.pojo.ClazzOption;
import org.example.bumenguanli.pojo.EmpQueryParam;
import org.example.bumenguanli.pojo.Student;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {


    List<Student> list(EmpQueryParam empQueryParam);
    @Insert("INSERT INTO student(name, no, gender, phone, id_card, is_college, " +
            "address, degree, graduation_date, clazz_id, violation_count, violation_score, " +
            "create_time, update_time) " +
            "VALUES (#{name}, #{no}, #{gender}, #{phone}, #{idCard}, " +
            "#{isCollege}, #{address}, #{degree}, #{graduationDate}, " +
            "#{clazzId}, #{violationCount}, #{violationScore}, #{createTime}" +
            ", #{updateTime})")
    void save(Student student);

    @Select("select id,name,no,gender,phone,id_card,is_college," +
            "address,degree,graduation_date,clazz_id,violation_count" +
            ",violation_score,create_time,update_time from student where id = #{id}")
    Student getinfo(Integer id);

    void update(Student student);

    void delete(List<Integer> ids);

    @Update("update student set violation_score = #{score}+violation_score" +
            ",violation_count =violation_count+1 where id = #{id}")
    void updateViolation(Integer id, Short score);

    @MapKey("pos")
    List<Map<String, Object>> studentCountData();

    @MapKey("name")
    List<Map> studentDegreeData();
}
